/**
 * Copyright (c) 2010-2011 Pierre Labatut
 *
 * This file is part of Space-Chronicles project.
 *
 * Space-Chronicles is free software: you can redistribute it and/or modify it
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or <http://code.google.com/p/space-chronicles/>.
 */
package space.app.common;

import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import space.debug.DbgError;

/**
 *
 * @author Pierre
 */
public class ErrorReportEventListener implements GLEventListener {

    final GLEventListener listener;

    public ErrorReportEventListener(GLEventListener listener) {
        if (listener == null) {
            throw new IllegalArgumentException();
        }
        this.listener = listener;
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        try {
            listener.reshape(drawable, x, y, width, height);
        } catch (RuntimeException ex) {
            DbgError.report(ex);
        }
    }

    public void init(GLAutoDrawable drawable) {
        try {
            listener.init(drawable);
        } catch (RuntimeException ex) {
            DbgError.report(ex);
        }
    }

    public void dispose(GLAutoDrawable drawable) {
        try {
            listener.dispose(drawable);
        } catch (RuntimeException ex) {
            DbgError.report(ex);
        }
    }

    public void display(GLAutoDrawable drawable) {
        try {
            listener.display(drawable);
        } catch (RuntimeException ex) {
            DbgError.report(ex);
        }
    }

    @Override
    public String toString() {
        return listener.toString();
    }
    
}
